#include <time.h>
#include <math.h>
#include <stdio.h>

void basic_test(const time_t interval){
	float r = 0;
	unsigned long e = 0;
	/*
	 * use clock higher resolution
	 *
	 * precision timer 
	 * clock and time 
	 * but they doesn't mean precise to microsecond
	 * best way is to use RDTSC
	 * */
	time_t st = time(0);
	/*
	 * in case of prediction 
	 * in case of optimise
	 *
	 */
	while(time(0) - st <= interval){
		r += sqrt(time(0));
		e++;
	}

	const unsigned long ui = (unsigned int)interval;
	printf("Executions in %lu seconds: %lu\n", interval, e);
	printf("Executions per millisecond: %lu\n", e/(1000 * ui));
	printf("Executions per microsecond: %lu\n", e/(1000000 * ui));
	printf("~%.lf executions every nanosecond\n", (float)e/(1000000000* ui));
	printf("%c\n", (char)r);

}
int main(){
	// run 3 seconds to test
	basic_test(3);
	return 0;
}
